﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ECommerce.BLL.Advertisement;
using ECommerce.Model.Advertisement;
using Jzy.BLL.SiteAdmin;
using Jzy.Model.SiteAdmin;

namespace ECommerce.Web.Site
{
    public partial class ArticleDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DispInfo();
                DispAdvertisement();
            }
        }

        private void DispInfo()
        {
            ArticleBO article = new ArticleBO();

            ArticleInfo info = article.GetInfo(Request.QueryString["ArticleID"]);
            litName.Text = info.Name;
            litInputTime.Text = info.InputTime.ToString("yyyy-MM-dd");
            litContent.Text = info.Content;
        }

        private void DispAdvertisement()
        {
            AdvertisementBO ad = new AdvertisementBO();
            List<AdvertisementInfo> list = ad.GetList();
            IEnumerable<AdvertisementInfo> tmp = list.Where(T => T.Name == "sub1");
            if (tmp.Count() > 0)
            {
                lnkSub1.HRef = tmp.First().Href;
                imgSub1.Src = tmp.First().BigImageAbsPath;
            }

            tmp = list.Where(T => T.Name == "sub2");
            if (tmp.Count() > 0)
            {
                lnkSub2.HRef = tmp.First().Href;
                imgSub2.Src = tmp.First().BigImageAbsPath;
            }

        }
    }


}